package com.szt.school.rabbitmq.topic;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TopicProducer {
    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send1(){
        String msg = "Hello, Topic1";
        System.out.println("生产者：发送 msg ‐> " + msg);
        amqpTemplate.convertAndSend("my_topic_exchange", "topic.test.msg1", msg);
    }

    public void send2(){
        String msg = "Hello, Topic2";
        System.out.println("生产者：发送 msg ‐> " + msg);
        amqpTemplate.convertAndSend("my_topic_exchange", "topic.info.str", msg);
    }
}
